"""
第十六条线性用例模块
测试更改个人信息-输入手机号10位
"""

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
# 进入crm
driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.maximize_window()
driver.get('http://192.168.1.25/crm')

'''登录'''
# 定位器
username_locator = (By.NAME, 'name')
password_locator = (By.NAME, 'password')
btn_locator = (By.NAME, "submit")

geren_btn_locator = (By.XPATH, '/html/body/div[1]/div/div/div[2]/ul[2]/li[6]/a')
gerenziliao_btn_locator = (By.LINK_TEXT, "个人资料")

bumen_select_locator = (By.ID, 'department')
gangwei_select_locator = (By.ID, 'role')
youxiang_locator = (By.NAME,'email')
shouji_locator = (By.NAME,'telephone')
baocun_locator = (By.NAME,"submit")

# 元素实体化
yonghuming_srk=driver.find_element(*username_locator)
mima_srk=driver.find_element(*password_locator)
denglu_anniu=driver.find_element(*btn_locator)
# touxiang_anniu=driver.find_element(*geren_btn_locator)
# gerenziliao_anniu=driver.find_element(*gerenziliao_btn_locator)
# bumen_xlk=driver.find_element(*bumen_select_locator)
# gangwei_xlk=driver.find_element(*gangwei_select_locator)
# youxiang_srk=driver.find_element(*youxiang_locator)
# shouji_srk=driver.find_element(*shouji_locator)
# baocun_anniu=driver.find_element(*baocun_locator)

# 登录操作
yonghuming_srk.send_keys("admin")
mima_srk.send_keys('123456')
sleep(2)
denglu_anniu.click()
sleep(1)
# 点击进入个人资料
driver.find_element(*geren_btn_locator).click()
driver.find_element(*gerenziliao_btn_locator).click()
# 选择岗位与部门
Select(driver.find_element(*bumen_select_locator)).select_by_index(1)
Select(driver.find_element(*gangwei_select_locator)).select_by_index(1)
# 输入手机号与邮箱
driver.find_element(*shouji_locator).clear()
driver.find_element(*shouji_locator).send_keys('1356666888')
sleep(5)
driver.find_element(*youxiang_locator).clear()
driver.find_element(*youxiang_locator).send_keys('1234@qq.com')
# 点击保存
sleep(2)
driver.find_element(*baocun_locator).click()

'''清理环境'''
sleep(2)
driver.quit()